#!/bin/env bash

# DON'T EXECUTE THIS SCRIPT DIRECTLY!
printf "Don't execute this script directly.\n"
exit

# For more detail, see
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

# GENERATE A NEW KEY
# -t stands for type (the type of algorithm you use to generate the key)
# -C stands for comment (feel free to change it)
ssh-keygen -t ed25519 -C "chiyuquan@user.noreply.gitee.com"

# ADD THE PRIVATE KEY TO SSH-AGENT
# THIS STEP NEEDS TO BE DONE EVERY TIME IN A NEW TERMINAL SESSION
# start ssh-agent in the background
eval "$(ssh-agent -s)"
# add your private key to the ssh-agent
# remember to adjust the path if you didn't use the default
ssh-add ~/.ssh/id_ed25519

# ADD THE PUBLIC KEY TO YOUR ACCOUNT
cat ~/.ssh/id_ed25519.pub
# copy the output to appropriate destination

# TEST CONNECTION
ssh -T git@github.com
